package javacourse.mq.mymq.Controller;

import javacourse.mq.mymq.service.QueueOperator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Create by chenhd on 2021/11/6.
 */
@RestController
@RequestMapping("/api/mqClient")
public class ProducerController {
    @Autowired
    QueueOperator queueOperator;

    /**
     * 生产消息
     *
     * @param topic
     * @param message
     * @return
     */
    @RequestMapping("/produce")
    public String produceMessage(String topic, String message) {
        if (queueOperator.produce(topic, message)) {
            return "ok";
        }
        return "fail";
    }
}
